#!/usr/bin/perl
#index.cgi

require './protocolman-lib.pl';

&ReadParse();

&header($text{'protocols_title'}, "", "index", 0, 1, undef, undef, "<meta http-equiv=refresh content=60>");
#print "<hr>\n";
print "<form name=editform action=edit_protocol.cgi method=post onsubmit='disable_buttons()'>\n";
&list_protocols;

print <<EOF;
<script>
function set_oper_type(obj)
{
	var i;
	found = false;

	for(i = 0; i < document.editform.protocol.length; i++)
	{
		if (document.editform.protocol[i].checked)
		{
			found = true;
			document.editform.protocoltype.value = document.editform.protocol[i].value;
			break;
		}
	}

	if (!found)
	{
		alert("$text{'noselectprotocol'}");
		return false;
	}

	if (obj == document.editform.startservice)
	{
		document.editform.opertype.value = "s";
	}
	else if (obj == document.editform.stopservice)
	{
		document.editform.opertype.value = "t";
	}
	else if (obj == document.editform.restartservice)
	{
		document.editform.opertype.value = "r";
	}
	else
	{
		document.editform.opertype.value = "p";
	}
}

function disable_buttons()
{
	document.forms[0].startservice.disabled = true;
	document.forms[0].stopservice.disabled = true;
	document.forms[0].restartservice.disabled = true;
	document.forms[0].serviceproperty.disabled =true;
}
</script>
EOF


print "<input type=hidden name=opertype>\n";
print "<input type=hidden name=protocoltype>\n";
#print "<input type=submit class=button1 name=startservice value='$text{'start_service'}', onclick='return set_oper_type(this)' style='border-width: 1'>\n";
#print "<input type=submit class=button1 name=stopservice value='$text{'stop_service'}', onclick='return set_oper_type(this)' style='border-width: 1'>\n";
#print "<input type=submit class=button1 name=restartservice value='$text{'restart_service'}', onclick='return set_oper_type(this)' style='border-width: 1'>\n";
#print "<input type=submit class=button1 name=serviceproperty value='$text{'service_property'}', onclick='return set_oper_type(this)' style='border-width: 1'>\n";
print "</form>\n";
#print "<hr>\n";
&footer("/", $text{'index'});
